<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <canvas id="canvas" width="500" height="500"></canvas>
</body>
<script>
    let ctx = document.getElementById("canvas").getContext("2d");
    let img  = new Image;
    img.src ="./img/th.jpg";
    img.onload = function(){
        let pat = ctx.createPattern(img,'repeat-y');
        ctx.fillStyle = pat;
        // ctx.translate(0,300)
        ctx.fillRect(0,0,500,500);
    }
</script>
</html>